package com.wfw.gateway.controller;

import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by yuzhongbo on 2018/9/18.
 */
@EnableAutoConfiguration
@RestController
public class TestController {

    @GetMapping("/hystrixerror")
    public String hystrixerror(@RequestParam("name") String name) {
        System.out.println("name" + name);
        try {
            if (name.equals("open")) {
                Thread.sleep(6000L);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return name;
    }

    @GetMapping("/retryerror")
    public String retryerror(@RequestParam("name") String name) {
        System.out.println("name" + name);
        if (StringUtils.isBlank(name)) {
            System.out.println("error" + name);
            throw new RuntimeException("error");
        }
        return name;
    }

}
